This event occurs in Chapter 12 of the novel, and it is important to realise that, in terms of the character development of Huck, it happens very early on in the novel, when Huck is still very young and immature and has not experienced the events that serve to change him and make him grow up. His immaturity is shown straightaway by his intention to board this ship, even though Jim wisely counsels him to stay away from it. Note what Huck thinks:
Well, it being away in the night and stormy, and all so mysterious-like, I felt just the way any other boy would a felt when I see that wreck laying there so mournful and lonesome in the middle of the river. I wanted to get aboard her and slink around a little, and see what there was there.
Even though this steamer gives every appearance of being abandoned and the weather is terrible, Huck, because of his boyhood fascination with adventure and excitement, insists on ignoring Jim's good advice, and they board the ship, which, as it transpires, turns out very badly for them as they risk capture by these murderers, and Huck learns a very important lesson about heeding Jim's advice. In this incident the reader still sees a more immature, youthful Huck, who has been influenced strongly by his friendship with Tom Sawyer.