Fully sorting a list of elements is more work than a lot of real problems actually need. Many tasks only ever need to know one thing: what's the current highest-priority, smallest, or largest element in a changing collection, repeatedly, as elements get added and removed over time. A heap is a data structure built specifically for that narrower job — it never bothers maintaining full sorted order across all its elements, only just enough structural order to guarantee the single best element is always instantly accessible at the top.
A weaker guarantee than sorting, and a cheaper one to maintain
A heap is typically implemented as a specific kind of tree structure where each parent node satisfies a heap property relative to its children — in a min-heap, every parent is smaller than or equal to both of its children; in a max-heap, every parent is larger than or equal to both. Crucially, this property says nothing about how any two sibling nodes, or nodes in different branches of the tree, compare to each other — only the strict parent-child relationship along each path down the tree is guaranteed. That's a considerably weaker guarantee than full sorted order, which requires every element to have a definite, known position relative to every other element. The heap deliberately gives up that full ordering in exchange for something cheaper to maintain.
Why the weaker guarantee is exactly what makes it fast
Because a heap only has to preserve the narrower parent-child property, rather than a total order across every element, inserting a new element or removing the top element can each be done by adjusting a comparatively small number of nodes along a single path through the tree, rather than potentially reshuffling large portions of the whole structure the way inserting into a fully sorted list can require. This is exactly why heaps are the standard underlying structure for priority queues, used anywhere a program needs to repeatedly extract the current best-priority item from a constantly changing collection — task schedulers, pathfinding algorithms, and simulation systems that process events in time order all rely on a heap's ability to give instant access to the top element while keeping insertions and removals cheap, a combination that a fully sorted structure can't match as efficiently.
What we're still unsure about
The structural properties of heaps, and the efficiency guarantees they provide for insertion, removal, and finding the top element, are rigorously proven and well established in computer science, with predictable, well-analysed performance characteristics. What's more a matter of practical engineering judgement than settled theory is choosing between the several different heap variants that exist — binary heaps, binomial heaps, Fibonacci heaps, and others — each of which makes slightly different tradeoffs in the relative cost of different operations, and which variant is actually the best fit depends on the specific pattern of operations a given application performs most often, a choice that requires understanding the application's real usage pattern rather than following one universally best option.
This sits inside Heaps & Priority Queues, one of eight topics in Data Structures, one of seven domains in Computer Science, one of seventeen subjects the app can quiz you on.