how the heck can you connect anything to +5V sometimes and Ground sometimes? That doesn't make any sense! If the pin is an input, you have to send electricity to it, so you'd connect it to +5V, right? And if the pin is an output, you connect it to Ground, right?
Digital electronics has two "states": 1/0, on/off, high/low. Typically, 5V is a binary '1' or high, and 0V is a binary '0' or low. Ground is the reference, so when you connect an input to ground, it's 0V or digital-zero. If you connect an input to 5V, it's a digital-one.
It get's a little technical, because the voltages are not always exactly zero or 5V. There are specs and standards for different part-families, and there is a "safety margin". The output-specs are tighter than the input specs, so when a chip puts-out a "high" the voltage is always higher than the input needs to recognize it as high, and a "low" is always lower (closer to ground or closer to zero) than the input needs to recognize it as low.
When we think about "high" or "low", we usually don't worry about current-flow. We just want to know what the voltage-state is. We do have to think about current-flow when we are deciding to use a pull-up or pull-down resistor, and we are trying to figure-out what resistor value to use. Or, if we connect an LED to an output and we need to limit/control the current through the LED.
As you probably know, everything in the computer's memory is stored in binary (base-2, ones & zeros). That's all of the text, numbers, computer programs, etc. Thankfully, it gets "translated" so users and programmers that program in high-level languages (C/C++, Java, etc.) don't have to worry about that too much. But, sometimes you might want to convert a number in decimal (or hexadecimal) to create a particular binary number or "bit pattern" (or LED pattern) on the Arduino output.
If you connect an oscilloscope to a data bus (or address bus) line inside a computer, you will see it jumping like crazy between 0 and 5V (assuming a 5V bus).
If you could "hold" or "freeze" the data bus, you could look at all the data-lines and figure-out the binary nummber, but you wouldn't know what it means because you wouldnt know what the computer is doing at that microsecond.... On some systems, or some places in the system, the data/pattern is static, and you can measure/read the number. Where I work, we do this all the time... I can write a hexadecimal (base 16) 55, which translates to binary 010101... or hex AA, which translates to 101010... and I can test the data-lines with a 'scope or meter.