It’s not until the fifth serial of the original series that we have the second story to feature aliens other than the Doctor and Susan. It’s also, of course, our second alien planet, although the new series would take even longer to get around to that. The story
The Keys of Marinus has a poor reputation among many older fans, scoring badly in rankings on review aggregator websites. Unusually, however, it seems to be almost universally popular among fans of the modern series who dip into the classic one for the first time, perhaps because of the story structure. Despite being first broadcast in 1964, this resembles a video game and, importantly for our purposes, involves visiting different and varied locations as the protagonists collect the items that they need in order to leave.
Where & When
The story is set on the planet Marinus, which has no known connection to Earth. The world is barely even mentioned again, and never in any context that allows us to date this story. The implication would be that it’s a long way from Earth, probably in a different galaxy, but even that is supposition. Different fan theories and a comic story come up with wildly different answers from the distant past to the distant future. Without any connection to Earth, it honestly doesn’t matter.