The two main (hehe) theories I’ve read are that it hit a mine in Havana harbor that was out of place, or that a spark ignited the magazine, causing all the ships munitions to detonate. Of course, at the time, people like Joseph Pulitzer and William Randolph Hurst reported that it was a Spanish attack. Most historians agree that this was unlikely.
The real issue though is whether or not the sinking of the Maine was the reason for war, or merely an excuse. In Empire by Default by Ivan Musicant, the author paints a picture of president McKinley that suggests he wanted to avoid war at all costs. GJA O’Toole echoes these sentiments in The Spanish War. However, Bonnie M Miller, in her book From Liberation to Conquest, suggests that the familiar narrative is inaccurate. She points out that neither Hurst nor Pulitzer had the circulation necessary to influence the population of the United States to the degree that most historians claim. She argues that McKinley had imperialist designs all along, and uses the Teller Amendment and Platt Amendment as evidence.
The Teller Amendment, added to Congress’ declaration of war, prevented the US from annexing Cuba, but mentioned only Cuba. Following the short war, the US did annex all of Spain’s other possessions near America, including Puerto Rico, Guam and the Philippines. Shortly after, Congress passed the Platt Amendment, which basically allowed the US to remain in Cuba for the next 3 decades without formally annexing it. Also, keep in mind that during this same period, the US “acquired” Hawaii, although that was unrelated to the war with Spain.
All of this taken together does seem to suggest that McKinley was in fact an imperialist who simply used the explosion of the Maine as an excuse to get what he already wanted. Some have likely even suggested that he was somehow behind the explosion as part of a false flag operation, although I’m not aware of any evidence that supports that claim.
There's not a broad consensus, though common sense seems to point towards an internal explosion being the most likely cause.
Both u/thucydideswasawesome and u/the_alaskan have tackled this before:
and