The phenomenon of magnetism is one of the key components of today's technological progress. Magnetic interactions and magnetic materials are essential for the scientific disciplines of physics, chemistry and biology, making this subject truly multidisciplinary. This thesis is devoted to magnetic properties of two classes of substances. The first class represents the complexes of the ions of paramagnetic metals, primarily of the gadolinium(III) ion. These molecular compounds have an important application as magnetic resonance imaging (MRI) contrast agents for medical diagnostics. The design of more efficient MRI contrast agents requires a detailed knowledge of their magnetic properties. The other part of the thesis considers the broad class of recently discovered carbon nanostructures and materials. Their extraordinary physical properties foretell future applications of these materials in electronics, medicine and other fields. For instance, carbon nanotubes loaded with gadolinium(III) ion clusters are highly efficient MRI contrast agents. By using accurate density functional theory calculations in combination with classical molecular dynamics simulations, we determine hyperfine and quadrupole coupling constants on the nuclei of a first coordination sphere water molecule in gadolinium(III) aqua complexes. These parameters play a crucial role in the description of the key function, relaxivity, of MRI contrast agents. We found that the spin-polarization effect induced by the paramagnetic gadolinium(III) ion results in a Fermi contact hyperfine coupling of both the 1H and 17O nuclear spins and affects the dipole hyperfine coupling of the 17O nuclear spin of the inner coordination sphere water molecule. The 17O quadrupole coupling parameters of a coordinated water molecule are found to be very similar to that of neat water. We also apply the methodology of first principles molecular dynamics in order to perform realistic simulations of paramagnetic metal ions in water solution. This allows us to assess structure, dynamics and hyperfine interactions on the water molecules in the inner and outer coordination spheres of two metal ions: chromium(III) and gadolinium(III). In order to perform such calculations, we develop a novel approach for the evaluation of hyperfine coupling constants in pseudopotential electronic structure techniques. Our method takes into account the contribution of core electrons. In the second part of the thesis, we consider magnetic properties of a broad class of carbon nanostructures derived from two-dimensional graphene. We find that in metallic carbon nanotubes, an isotropic Knight shift, a hyperfine contribution to the nuclear magnetic resonance chemical shift, shows a regular dependence on the nanotube diameter. By using a more general approach, we reveal systematic dependences of magnetic interactions between arbitrarily distributed spin-polarized conduction electrons and nuclear spins in the carbon nanostructures derived from graphene. This knowledge is important for interpreting the results of magnetic resonance experiments and for evaluating the performance of carbon nanostructures as materials for alternative approaches in electronics, spintronics and quantum information processing based on electron and nuclear spins. In addition, we study magnetism in graphene induced by single-atom defects. The predicted itinerant magnetism due to the defect-induced states in graphenic materials may account for the experimental observations of ferromagnetism in irradiated graphite which has potential applications in technology. Finally, our first principles molecular dynamics study reveals the mechanisms of the irradiation-induced defect formation. We show that certain defect structures in layered carbon materials can be created selectively by irradiation at predefined conditions.