I got this pretty good question the other day - why does bitcoin have a value at all? After all it's nothing - who is willing to pay for nothing?
Like any other asset that has a market price, it's all a matter of supply and demand.
The supply side is relatively trivial, the protocol allows for a fixed amount (25 bitcoins at the time of writing) to be produced every tenth minute, this reward is cut in half at regular intervals, and with this algorithm there will never be more than 21 million coins. However, scarcity by itself is not sufficient, there needs to be a demand as well. There are many factors behind the demand, I believe none of them are sufficient alone, but some may be more important than others.
A working currency needs to be scarce, divisible, portable, durable, fungible and easy to verify. Bitcoin scores pretty well on those attributes and was the first digital currency to do so. However, it's not alone a guarantee to success. Other cryptocurrencies (aka "alt-coins") may be competitive on all the above.
The belief that Bitcoin will be a viable means of paying for goods and services in the future. This may cause a sustainable and predictable value. As an example, assume that 21 million people are buying bread with bitcoins, and in average they'd like to hold enough bitcoins in their wallets to buy 10 breads. For a brief moment, let's assume this is the only use-case scenario. With 21 million bitcoins in circulation, that means every user by average has one bitcoin in the wallet. The value of a bitcoin would then be ... exactly ten breads!
A belief that Bitcoin is "digital gold", a useful means of storing value. Someone even says ... "payments aren't important, bitcoin is the digital gold, and gold is rarely used for payments" - I believe that's dangerous. Gold has been established both as a currency and as a "holder for value" for millennias, while Bitcoin hasn't even been around for a decade. Traditionally almost every currency was both backed by gold and pegged to gold, so all until the 1970s one would indirectly use gold for paying for goods and services. Gold also has unique characteristics suiting this purpose, gold cannot easily be replaced by other metals while Bitcoins can easily be replaced - i.e. if another altcoin gets more popular than Bitcoin for payments, I predict the BTC-value will drop pretty fast.
Speculation - people hoard bitcoins because they expect the market price to increase further in the future. As of today, this is probably the biggest driver of demand, and it's by itself enough to spur a price growth, but it may not be sustainable. Critics compare Bitcoin to a ponzi scam, a pyramide scheme and tulip mania. Even though none of those comparitions quite hit the mark, if the value is only driven by speculation there is a risk that at some point there may be a crack and the value may fall very fast (like it did when MtGox failed).
Trust in the scarcity. The risk that the 21M hard limit will be increased through a protocol change is considered small. However, Bitcoin doesn't have a monopoly on cryptocurrency as such, it's easy to create new altcoins, and there are already hundreds of altcoins which could theoretically replace Bitcoin.
Trust in the security of the transactional system. The blockchain and proof-of-work delivered by the miners ensures that a transaction remains irreversable and that bitcoins cannot be double-spent. The cryptographical algorithms used for signing transactions ensures that nobody but the owner of the bitcoin can spend the bitcoin. It has been argued that the market cap of any cryptocoin have an upper bound in the security of the system; the market cap can never become so big that it would be profitable to buy the processing power needed to successfully double spend or brute-force-engineer private keys corresponding to existing valuable public keys. Reversely, the same argument can be used to prove that Bitcoin is a secure network (at least when neglecting the risk of phishing, robbery, social-engineering, gaining access to wallets through security holes, exploits or lax password security, missing backup, etc). The fact that the ledger is secured by an extreme amount of processing work may be one of the points where Bitcoins really excel compared to competitors.
The network effect - this is the (only) thing where Bitcoin excels on the altcoins. (Almost) everyone that accepts cryptocurrency accepts Bitcoins - but only some few accepts other cryptocurrencies. Never underestimate the network effect. Bitcoins may become worthless very fast if some other cryptocurrency takes it's place.
Usefulness for criminal purposes; Bitcoin is perceived to be anonymous, it can be very anonymous if one wants it to be, it crosses borders easily and without regulatory oversight, hence it's the ideal currency for ransom, tax evasion, drug smuggling, crime-as-a-service, etc. I sure do hope that this is a smaller driver for value than the usefulness for legitimate payments for goods and services.
Bitcoins have a value because their supply is limited and people want them. If someone is willing to buy a Bitcoin for $400, then it makes sense for you to value a Bitcoin at $400 because you know that you can sell it to them for $400.
This is essentially the same reason dollars have value. You value a dollar because you have a reasonable expectation that you can trade it for clothes or groceries in the future.
Bitcoin has value because it is used as a medium of exchange(currency) between buyers and sellers of goods. Currency solves the problem of having goods for sale that someone needs. Let's take an example from ancient times before currency existed. For example you have chickens and you collect their eggs, someone else wants those eggs but they don't have anything you want in exchange. Let's say the other person has a goat and let's say a third party does have something you need, cow's milk. How do you exchange your eggs for cow's milk when the person holding this item doesn't wasn't what you have. In this example we find out the milk holder does want a goat, so we could make a convoluted trade with all the parties where each party determines the value of the goods they hold and the goat could be traded for the milk, which could then be exchanged for the eggs you have and everyones happy right? Not everytime will this work so currency was created and maybe it just started out as IOUs on paper. Who would trust these IOUs? If someone didn't pay their debt the system crumbles.
Now enter the concept of crypto currency. Every token (or maybe IOU in this example) had a defined value (how many tokens/coins you hold) the system is able to determine who has how many tokens and they can be spent on a trustless manner (meaning no one can spend a coin they don't control, based on cryptographic proofs and the shared ledger) this allows anyone to pay any other individual as many tokens as they feel the item they are exchanging for is worth. This value gets determined by the market price someone is willing to pay for a token today. When bitcoin began it was near worthless, but as people began to realize it's utility as a mechanism of exchange with no borders and no one party in control it began being used at near zero value. Over time more and more people began seeing this utility and this the market drove the price to what it is today.
I encourage you to further research the beginnings of currency and what its implications were when it began. It gave the person with eggs the ability to pay for the milk that they needed without having to jump through hoops and hoping someone needed what they have for exchange by creating a solution out of nothing. Hope this answers your question.
Why do euros or dollars or pounds on your bank account have value? After all, they're nothing. They don't even exist, money on a bank account is purely fictional. Who's willing to pay (or work) for something that doesn't even exist?
The reason a bitcoin has value is because of its utility (an extremely efficient, fast, easy, frictionless, safe, unrestricted money and payment system) combined with its scarcity.
Water is useful, but generally not scarce. My toenail clippings are scarce, but not useful. But the more people consider something to be useful (and with Bitcoin, there are plenty of reasons why people find it useful) the higher the demand. Yet the supply is limited, and price is essentially determined by demand vs supply, thus it has value.