Molech was an idol at the time the Torah was given. While idolatry is generally prohibited, the service of Molech was particularly heinous, so we are given an extra mitzvah specifically banning its service.
The service of Molech is that the parent of a child would hand it over to the priests of the idol, who would hold the child in the idol’s face. They would then return the child to the parent, who would pass him through a large fire. The commentators differ as to whether the intention of this service was to sacrifice the child in the fire or merely to pass him through it as unscathed as possible. In either case, this is a spectacularly bad idea. (If someone nowadays passed their child through a fire, how long do you think it would before that person’s kids were taken away and placed in protective custody?)
As bad as Molech is, does it really require its own prohibition on top of the existing bans on idolatry? According to the commentary of the Ramban (Nachmanides) on Leviticus 20:5, this mitzvah actually adds a whole new dimension. One is normally only culpable for serving an idol in its normal fashion. If one were to worship Odin using the service of Zeus (assuming they were different), it would be forbidden but not a capital crime. Verse 20:5 warns us not to stray after the service of Molech. From here, the Ramban says, we are liable for passing a child through fire for any idol, even though doing so is specifically the service of Molech.
There are several rationales underlying this mitzvah. The first is that idolatry in general is an affront to God. Worshipping a block of wood or a hunk of stone instead of the Creator is a terribly offensive thing to do. The second aspect is the reprehensibility of murder. All human life is precious, but to kill one’s own children? That’s REALLY low. (Even if the service only entailed child endangerment, the person offering their child to Molech still fails as a parent and as a human being.)
This mitzvah applies in all times and places. It is discussed in the Talmud in tractate Sanhedrin on pages 64a-b. It is codified in the Mishneh Torah in the sixth chapter of Hilchos Avodas Kochavim. This prohibition is #7 of the 365 negative mitzvos in the Rambam’s Sefer HaMitzvos. It is not in the Sefer HaMitzvos HaKatzar of the Chofetz Chaim.