Questions & Answers about В поезде мне хорошо спится.
В поезде means inside the train (physically in the carriage), so Russian uses в + prepositional case for being inside an enclosed space: в поезде.
На поезде is normally used in the sense of by train / using the train as transport (less common than other options), similar to talking about the mode of travel. Much more standard for “by train” is на поезде or поездом (instrumental), but your sentence is about where you are when you sleep well, so в поезде is the natural choice.
Поезде is prepositional case (also called locative in some contexts), used after в to indicate location: в поезде = in the train.
The dictionary form is поезд. In the prepositional singular it becomes (в) поезде.