I am well aware of the math behind the RSA encryption system, and why it works. The bank, for example, publishes a pair of numbers $(e,n)$ which are used for encryption by the customers. The bank then changes the number $e$ to $d$ and uses the pair $(d,n)$ to decrypt the message. Only a person with the number $d$ could decrypt the message, and only the bank has it, as it only published the numbers $e$ and $n$ - NOT $d$. I won't go into details about why and how it works - not because it's difficult but because it's a long explanation.
But anyways, the math behind this deal states that $$d = \frac{2\cdot\phi(n)+1}{e}$$ Now, we said that $e$ and $n$ are given, then what's the problem decrypting the message? One could easily find $d$, right? NO. $e$ is simple enough to insert into the above, but calculating $\phi(n)$ becomes a very difficult task given that $n$ is sufficiently large, because factorizing an integer is a difficult task. It's been found by Euler that $$\phi(n) = n\cdot\prod_{p|n}(1-\frac1p)$$ where the product runs over the prime factors of $n$.
Now, given $n=p\cdot q$ and $p$ and $q$ are prime, we get that $$\phi(n)=(p-1)\cdot (q-1)$$ So what the bank does, is they choose $n$ such that it will be large and difficult to factorize, and people won't be able to find the prime factors of $n$, rendering them unable to find $d$ and decrypt message, passwords, and break into others' bank accounts. They choose $n$ to be semiprime (multiplication of just 2 prime numbers) becaue it's the most difficult to factorize. I understand that the modern technology doesn't allow these $n$ to be easily factorized, but my question, given that the bank has more or less the same technology as other high-tech companies, is how does the bank itself come up with these semiprimes $n$ and primes $p$ and $q$ from the first place? Some $n$ are 600+ digits long, which makes $p$ and $q$ already difficult enough to be proven prime (certain primality tests for 300+ digits' numbers). So how do banks and other companies such as google, twitter, facebook and others come up with these numbers?
How is it that they themselves are able to find such numbers which they claim will take modern computers thousands of years to factorize?
This can just be done by trial and error, because large-ish primes (say with 200 digits or more) aren't really that rare. About 1 in $\frac{1}{\log N}$ numbers near $N$ are prime. For $N = 10^{100}$, about one in 230 integers this number are prime. Since you know that even numbers or numbers ending in 5 aren't prime, you have to test 100 numbers on average to find a 100 digit prime.
The second ingredient is that testing whether a number is prime can be done very quickly, unlike actual factoring, using primality tests such as the Miller-Rabin test.
For example. the smallest prime number with 100 digits is $10^{99} + 289$. The next one is $10^{99} + 303$. The one after that is $10^{99} + 711$. The one after that is larger than $10^{99} + 999$. That's three primes in an interval of length 1000, which is reasonable close to 1 in 230.