Edit: Long answer to understand what happens
(For shorter answer look at @Henri Menke's answer)
Many LaTeX users are also programmers, and being a LaTeX user you become somehow a kind of programmer. Coding has some rules on styling our structure and so writing a C program we may choose between the following styles:
1.
#include <stdio.h>
int main(void)
{
int i=0;
for (i=0;i<10;i++)
{
printf("Loop Count i=%d",i);
}
return 0;
}
2.
#include <stdio.h>
int main(void){
int i=0;
for (i=0;i<10;i++){
printf("Loop Count i=%d",i);
}
return 0;
}
or 3.
#include <stdio.h>
int main(void){
int i=0;
for (i=0;i<10;i++){printf("Loop Count i=%d",i);}
return 0;
}
In C programming the result is exactly the same but something similar in LaTeX coding will not have the same results.
Empty lines
One reason is that in LaTeX coding, an empty line is equivalent to a \par command and inserts a paragraph. So the next example will generate the following output:
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{parskip}
\setlength{\parindent}{8pt}
\setlength{\parskip}{15pt}
\newcommand{\myprint}[1]{
#1
}
\begin{document}
\section{In a section}
First line in first section
\def\mymaintext{This is my text that will occupy a big part of remaining line.}
Test before.\mymaintext
Test line after.
Test before.\myprint{\mymaintext}
Test line after.
\end{document}

Spaces
By removing the empty lines we remove the \par commands from our print command but we don't remove the spaces:
\newcommand{\myprint}[1]{
#1
}
The above command will generate an extra space before our argument (we will have one space there) and an extra space after (two spaces after).
The following changes are equivalent:
\newcommand{\myprint}[1]{#1}
or
\newcommand{\myprint}[1]{%
#1%
}
and we have removed the extra empty spaces.
For more look at the topic of space tokens that @TH. gave me in the comments of the question.
The following answer was my first answer before understanding exactly what happens and I'm leaving it here for someone who will read the comments
I don't really know why it happens, but I found that a solution is to print in a minipage of width=\linewidth.
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\setlength\parskip{10pt}
\setlength\parindent{0pt}
\newcommand{\myprint}[1]{
\begin{minipage}{\linewidth}
#1
\end{minipage}
}
\begin{document}
\section{In a section}
This is a text that will occupy one full line and some more, I hope I can show it
\myprint{This is a text that will occupy one full line and some more, I hope I can show it}
\end{document}
Output:

\myprintmacro. Put % at the end of the two lines. – TH. Jun 27 '17 at 00:14{and one after the#1from the new lines. You need to add a comment character after both to prevent that. – TH. Jun 27 '17 at 00:18\newcommand{\myprint}[1]{#1}all on the same line. Incidentally, in your example the first space actually has no effect because occurs in vertical mode; it will not be so in general. – GuM Jun 27 '17 at 00:23\newcommand{\myprint}[1]{#1}or something equivalent. What you have now is equivalent to\newcommand{\myprint}[1]{ #1 }which has more spaces. – ShreevatsaR Jun 27 '17 at 00:23