From Robert Foster's A Guide to Middle Earth which is generally very definitive:
STONE-GIANTS Creatures of great size and strength living in the high passes of the northern Misty Mountains. The stone-giants are mentioned only in The Hobbit, and may be no more serious than Golfimbul.
Rather unpromising. There's also the section in 'The Ring Goes South' (this is a second-hand quote; I don't have my physical copy on me to double check this)
"It may have been only a trick of the wind...,but the sounds were those of shrill cries, and wild howls of laughter. Stones began to fall from the mountain-side, whistling over their heads, or crashing on the path besides them...
'We cannot go further tonight,' said Boromir. 'Let those call it the wind who will; there are fell voices on the air; and those stones are aimed at us.'
'I do call it the wind,' said Aragorn. 'But that does not make what you say untrue. There are many evil and unfriendly things in the world that have little love for those that go on two legs, and yet are not in league with Sauron, but have purposes of their own. Some have been in this world longer than he.'
It does not explicitly name stone-giants, but it has the generally correct location/appearance.
The Tolkien Gateway page has a pretty solid exposition - notable tidbits:
A local legend among the indigenous people of Gondor told of giants making the White Mountains, to keep Men out of their lands by the Sea. One of them, Tarlang, tripped, and broke his neck. The other giants did not clean up his body, which became incorporated in the land instead. The giant's neck became Tarlang's Neck, his head Dol Tarlang, and the stones he was carrying Cûl Veleg and Cûl Bîn.
So perhaps there is some backstory to the giants; relatedly, this is very reminiscent of the Norse creation myth with Ymir. It could be that incorporating giants was part of Tolkien's tendency to 'retell' mythologies in a consistent fashion - to talk about Norse myth without mentioning giants would be rather difficult.
There's also the mentioned theory from The Annotated Hobbit on the same Tolkien Gateway page:
Douglas A. Anderson's annotations in The Annotated Hobbit: Revised and Expanded Edition express the opinion that stone-giants are a variety of troll.
Later sections of the wiki article talk about and support an alternate theory (and the one I think makes the most sense) - the stone-giants are a sort of evil/harsher Ent variant:
Giants originally had a larger part in the legendarium. In one early manuscript, the giants are counted among the Úvanimor, servants of Melko. In another manuscript, the giants are counted among the Earthlings, and are divided between the "wood-giants" (Qenya ulbandi) and "mountainous-giants" (Qenya taulir).
in early versions of The Lord of the Rings it was the Giant Treebeard who held Gandalf captive, not Saruman [...] As Christopher Tolkien notes, "Ent" comes from an Old English word for "giant"
Also, to quote from the SE answer Rand al'Thor linked in comments:
An interesting note attached to the development of the Treebeard chapter, and given in [History of Middle Earth] 7 (Treason of Isengard) reads:
Difference between trolls - stone inhabited by goblin-spirit, stone-giants, and the 'tree-folk'.
So again, this sort of backs up this relation between Ents and giants that may have never been quite resolved.
But the same article talks about alternate theories where giants are a sub-race/variant of Men (sort of like hobbits, but in the other direction).
Last but not least, I will mention the similarity to C.S. Lewis' giants in The Silver Chair - since the two wrote together, there may have been some inspiration in either direction; that said, Tolkien regularly got annoyed by Lewis' relatively haphazard approach to worldbuilding. (Frankly, it's just as likely both drew on similar source material - Norse myth.)
So to sum up: stone-giants fall prey to Tolkien's tendency to write and rewrite large amounts of lore. The 'true' answer could be buried in some of his unpublished papers; far more likely is simply that there are multiple answers, much like the myth Tolkien was trying to emulate.
Edited to add something slightly tangential, but I think it's important.
The other answer on this question mentions that since The Hobbit is aimed more towards children than Tolkien's later published works/earlier personal writings, expecting an answer is a bit hopeless. Hopefully I've addressed this somewhat in the above, but I really want to address the idea that The Hobbit is more shallow since it's more aimed at children.
If you read through Tolkien's On Fairy Stories, we hit the following (bolding my own):
Among those who still have enough wisdom not to think fairy-stories pernicious, the common opinion seems to be that there is a natural connexion between the minds of children and fairy-stories, of the same order as the connexion between children’s bodies and milk. I think this is an error; at best an error of false sentiment, and one that is therefore most often made by those who, for whatever private reason (such as childlessness), tend to think of children as a special kind of creature, almost a different race, rather than as normal, if immature, members of a particular family, and of the human family at large.
Tolkien not only didn't think that fairy stories were only for children, he firmly believed that children weren't some separate class of being to be talked down to. And yes, The Hobbit is clearly a less developed work - the naming of the trolls is enough evidence of this - but it was written down because his son pointed out inconsistencies, forcing him to keep notes on the tale he was telling. And if you read through Tolkien's other more 'child-friendly' works, like Roverandom, they deal with some pretty heavy themes, just like The Hobbit, and they're just as well written and carefully thought out (in my opinion, at least) as The Hobbit. The Hobbit may be slightly more whimsical, but the whimsy came from somewhere - see for instance, in The Book of Lost Tales, Vol. 1 (alternatively History of Middle Earth Vol. 1) the story about the garden where dreaming children go. This is a serious story, but also a very curious/whimsical one, in some ways.
The diction of The Hobbit may be more child-friendly, but the content, the thought behind it, was no less serious, at least in my opinion. I think it's important to treat The Hobbit and the referenced things within it with as much seriousness as we'd treat a reference in The Silmarillion - and it's notable that in the revised edition where the section with Gollum and the ring was brought into line with The Lord of the Rings, the section with the stone-giants was left unchanged, though references to goblins were removed in various places and so forth (see this delightful forum thread which compares the editions literally line by line). Tolkien chose to leave it in, and I think that's telling.
Sorry, I'm aware this was only vaguely coherent, as a tangent, but I do hope it makes clear that stone-giants, as whimsical and random as they may seem, do fit into the broader world Tolkien was building, in really fundamental ways. The process of revision and re-revision and re-re-revision Tolkien used may make it unclear which interpretation is the correct one, but I have no doubt that if you'd asked him, he would have had an answer (that may have changed over time, but there would've been one).